import { IdentigoServer } from "../../identigo-node-sdk/src/Identigo";

const identigo = new IdentigoServer("http://localhost:3000", appSecret);

identigo.eventEmitter.on("ready", () => {
  console.log("Identigo Ready");
});

async function init() {
  await identigo.init();

  try {
    const users = await identigo.userService.getAllUsers();
    console.log(users);

    const attribute = await identigo.userService.getAttribute(
      users[0]._id,
      "customerId"
    );
    console.log("User customerId: ", attribute);

    const roles = identigo.userService.getUserRoles(users[0]._id);
    console.log("User Roles:", roles);

    const hasRole = identigo.userService.hasRole(users[0]._id, "admin");
    console.log("User has admin role: ", hasRole);

    const r = await identigo.userService.addRole(users[0]._id, "standard");
    console.log(r);

    const rr = await identigo.userService.removeRole(users[0]._id, "standard");
    console.log(rr);

    const a = await identigo.userService.addUpdateAttribute(
      users[0]._id,
      "test",
      "test"
    );
    console.log(a.message);

    const d = await identigo.userService.removeAttribute(users[0]._id, "test");
    console.log(d.message);

    const verified = await identigo.verifyToken(token);
    console.log("Verified: ", verified);
  } catch (err) {
    console.log("Something went wrong, use the err to see what");
  }
}

init();
process.on("uncaughtException", function (err) {});

Powered by Doctave